﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Xml.Linq;
using ClassLibrary.DAO;
using ClassLibrary.Entity;

public partial class MasterPage : System.Web.UI.MasterPage
{
    TblCategoriesDAO CategoriesDAO = new TblCategoriesDAO(Global.CONNECTION_STRING);
    TblGroupDAO GroupDAO = new TblGroupDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadMenu1();
            LoadMenu2();
            LoadMenu3();
            LoadMenu4();
            LoadGroup();
            LoadCSS();
        }
    }

    private void LoadCSS()
    {
        string idCSS = Global.GetPageName(Request.ServerVariables["SCRIPT_NAME"].ToString());
        if ((idCSS == "index.aspx"))
        {
            idbody.Attributes.Add("style", "background-image: url(images/bg_img_001.jpg)");
        }
        if ((idCSS == "Charms.aspx"))
        {
            idbody.Attributes.Add("style", "background-image: url(images/bg_img_002.jpg)");
        }
    }

    private void LoadGroup()
    {
        reGroup.DataSource = GroupDAO.GetGroup();
        reGroup.DataBind();
    }

    private void LoadMenu4()
    {
        reInspiration.DataSource = CategoriesDAO.GetCateByGroupID(4);
        reInspiration.DataBind();
    }

    private void LoadMenu3()
    {
        reGestalten_Kombinieren.DataSource = CategoriesDAO.GetCateByGroupID(3);
        reGestalten_Kombinieren.DataBind();
    }

    private void LoadMenu2()
    {
        reKollektionen.DataSource = CategoriesDAO.GetCateByGroupID(2);
        reKollektionen.DataBind();
    }

    private void LoadMenu1()
    {
        reProdukte.DataSource = CategoriesDAO.GetCateByGroupID(1);
        reProdukte.DataBind();
    }
    protected void reGroup_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item ||
            e.Item.ItemType == ListItemType.AlternatingItem)
        {
            RepeaterItem dataItem = (RepeaterItem)e.Item;
            string hid = DataBinder.Eval(dataItem.DataItem, "IDGroup").ToString();
            HiddenField hidGId = (HiddenField)e.Item.FindControl("hidGId");
            hidGId.Value = hid;
            HyperLink HypeID = (HyperLink)e.Item.FindControl("HypeID");
            if (hid == "1")
                HypeID.Attributes.Add("rel", "p1003176966514A29A2D7A42104574DC8");
            if (hid == "2")
                HypeID.Attributes.Add("rel", "p168C9CBCECB249B790A20A361026D4E8");
            if (hid == "3")
                HypeID.Attributes.Add("rel", "p4851B7298610415A8A617B829FF3CCA0");
            if (hid == "4")
                HypeID.Attributes.Add("rel", "pC862AEACCCAF41F0B56FF43A1F95329C");
            //DataTable dtGroup = GroupDAO.GetGroup();
            //foreach (DataRow dr in dtGroup.Rows)
            //{
 
            //}
        }
    }
}
